package com.aiyan.edu.framework.model.response;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author: zqzhou
 * @create: 2019/10/05 23:07
 **/
@Data
@ToString
@NoArgsConstructor
public class ResponseResult implements Response {

    /**
     * 操作是否成功
     * true 操作成功
     * false 操作失败
     */
    private boolean success = SUCCESS;

    /**
     * 响应代码
     */
    private int code = SUCCESS_CODE;

    /**
     * 提示信息
     */
    private String message = SUCCESS_MSG;

    public ResponseResult(ResultCode resultCode) {
        this.success = resultCode.success();
        this.code = resultCode.code();
        this.message = resultCode.message();
    }

    /**
     * 成功响应
     *
     * @return
     */
    public static ResponseResult SUCCESS() {
        return new ResponseResult();
    }

    /**
     * 失败响应
     *
     * @return
     */
    public static ResponseResult FAIL() {
        return new ResponseResult(CommonCode.FAIL);
    }
}
